package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.EmployeeBean;
import com.project.mapper.IEmployeeMapper;
import com.project.mapper.IProgressMapper;
import com.project.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.awt.event.KeyListener;
import java.util.List;
@Service
@Transactional
public class EmployeeServiceImpl implements IEmployeeService {
    @Autowired
    private IEmployeeMapper mapper;

    @Override
    public void add(EmployeeBean employee) {
        mapper.add(employee);
    }

    @Override
    public void quit(Integer emId) {
        mapper.quit(emId);
    }

    @Override
    public void update(Integer emId, String newPhone, Integer newSalary) {
        mapper.update(emId,newPhone,newSalary);
    }

    @Override
    public EmployeeBean findById(Integer emId) {
        return mapper.findById(emId);
    }

    @Override
    public EmployeeBean findByIdAndProceed(Integer emId) {
        return mapper.findByIdAndProceed(emId);
    }

    @Override
    public List<EmployeeBean> findByItem(String name, Integer prjId, String skill) {
        return mapper.findByItem(name,prjId,skill);
    }

    @Override
    public PageInfo<EmployeeBean> cutByItem(int pageNO, String name, String skill, String status, String sort) {
        PageHelper.startPage(pageNO,3);
        PageInfo pageInfo = PageInfo.of(mapper.cutByItem(name, skill,status,sort));
        return pageInfo;
    }
}
